package Tree_09.HuffmanTree_05;

/*
 * @Author 罗
 * @date 2020/3/22 - 10:39 下午
 *
 */

/**
 * 注意Comparable接口中泛型的使用
 * 若该接口定义了泛型，则compareTo()方法传入的就是泛型的对象类型
 */
public class Node implements Comparable<Node> {
    //权值
    int value;
    Node left;
    Node right;

    public Node(int value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return "Node{" +
                "value=" + value +
                '}';
    }

    @Override
    public int compareTo(Node o) {
        return this.value - o.value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public void setLeft(Node left) {
        this.left = left;
    }

    public void setRight(Node right) {
        this.right = right;
    }

    public int getValue() {
        return value;
    }

    public Node getLeft() {
        return left;
    }

    public Node getRight() {
        return right;
    }
}
